/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mirac
 * Date: 2025-07-21
 * Time: 12:48
 */


public class Main_3 {

    public static int getElement(int[] arr,int x) {
        if(arr == null) {
            throw new NullPointerException("传递的数组为null");
        }

        if(x < 0||x >= arr.length) {
            throw new ArrayIndexOutOfBoundsException("传递的数组下标越界");
        }

        return arr[x];
    }
    public static void main(String[] args) {
        int[] arr = {1,2,3};
        try {
            int ans = getElement(arr,4);
        }catch (NullPointerException e) {
            System.out.println("问题解决了");
        }
        catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("问题解决了");
        }finally {
            System.out.println("111111");
        }

        System.out.println("程序继续运行");
        System.out.println("123456");
    }
}
